import { createRouter, createWebHistory, createWebHashHistory, createMemoryHistory } from 'vue-router'
import usePermission from './permission'

// 可以省略的 扩展名  https://cn.vite.dev/config/shared-options.html#resolve-extensions


// @代表
import Layout from '@/views/Home.vue'
import Login from '@/views/Login.vue'
import NotFound from '@/views/NotFound.vue'
import User from '@/views/system/user/index.vue'
import Role from '@/views/system/role/index.vue'
import RoleEdit from '@/views/system/role/edit.vue'
import IndexHome from '@/views/index/index.vue'


// createWebHistory(),    history 
// createWebHashHistory   hash锚点  不会引起页面刷新  

const router = createRouter({

  history: createWebHistory(),
  routes: [
    {
      path: '/',
      name: 'Home',
      component: Layout,
      redirect: '/index',
      children: [
        {
          name: 'IndexHome',
          path: '/index',
          component: IndexHome,
          meta: {
            title: '首页',
            icon: 'home'
          }
        },
      ]
    },

    {
      path: '/system',
      name: 'System',
      component: Layout,
      children: [
        {
          name: 'User',
          path: '/system/user',
          component: User,
          meta: {
            title: '用户管理',
            icon: 'view'
          }
        },

        // 角色列表
        {
          name: 'Role',
          path: '/system/role',
          component: Role,
          meta: {
            title: '角色管理',
            icon: 'user'
          }
        },
       
      ]
    },


    {
      path: '/monitor',
      name: 'Monitor',
      component: Layout,
      children: [
        {
          name: 'Online',
          path: '/monitor/online',
          component: () => import('@/views/monitor/online/index.vue'),
          meta: {
            title: '在线用户',
            icon: 'user'
          }
        },

      ]
    },
    {
      name: 'Login',
      path: '/login',
      component: Login,
      meta: {
        title: '用户管理',
        icon: 'user'
      }
    },
    { path: '/:pathMatch(.*)*', name: 'NotFound', component: NotFound },




  ],
})

//使用 router  每一次切换路由的时候  做权限判断 
usePermission(router)

export default router